//
//  MobroControllAppViewController.h
//  MobroControllApp
//
//  Created by Óbudai Egyetem on 2011.11.13..
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreVideo/CoreVideo.h>
#import <CoreMedia/CoreMedia.h>

@interface MobroControllAppViewController : UIViewController <AVCaptureVideoDataOutputSampleBufferDelegate>
{
    
    AVCaptureSession            *capturedSession;
    AVCaptureVideoPreviewLayer  *previewLayer;
    AVCaptureStillImageOutput	*capturedStillImageOutput;
	AVCaptureVideoOrientation	orientation;
    
    BOOL                        cameraLocked;
    
    AVCaptureDevice             *device;
    
    IBOutlet UITextField        *address;
    IBOutlet UITextField        *dataPort;
    IBOutlet UITextField        *commandPort;      
    
    NSData                      *PNGImageData;
    NSData                      *JPEGImageData;
    
}

-(IBAction) keyAway:(id)sender;
-(IBAction) start:(id)sender;

@property (nonatomic, retain)       IBOutlet        UIImageView                 *backgroundImageView;
@property (nonatomic, retain)       IBOutlet        UIImage                     *takenPic;    

@property (readwrite, nonatomic, retain)            NSData                      *PNGImageData;
@property (readwrite, nonatomic, retain)            NSData                      *JPEGImageData;

@property (nonatomic, retain)						AVCaptureSession			*capturedSession;
@property (nonatomic, retain)                       AVCaptureVideoPreviewLayer  *previewLayer;
@property (nonatomic, retain)						AVCaptureStillImageOutput	*capturedStillImageOutput;
@property (nonatomic,assign)						AVCaptureVideoOrientation	orientation;

- (AVCaptureConnection *)connectionWithMediaType:(NSString *)mediaType fromConnections:(NSArray *)connections;

// AVFoundation (Camera) Methods
- (void)setupCaptureSession;
- (void)captureStillImage;
- (void)autofocusNotSupported;
- (void)flashNotSupported;
- (void)captureStillImageFailedWithError:(NSError*)error;
- (void)cameraOn;
- (void)cameraOff;

-(BOOL) getConnectState;
-(BOOL) Connector: (NSString*) addressString:(NSString*) portString;
-(BOOL) Disconnector;

@end
